|
|
|
|
|
|
|
Dim rs As Recordset
Dim dbName As String
Dim tabName As String
dbName = App.Path + "\abc.mdb"
tabName = "Customers"
On Error GoTo FormLoadErr
Set db = DBEngine.OpenDatabase(dbName)
Set rs = db.OpenRecordset(tabName, dbOpenTable,
_dbDenyRead + dbDenyWrite) ' table opened exclusively
MsgBox "Table opened exclusively"
GoTo FormLoadExit
FormLoadErr:
MsgBox "Unable to load table exclusively"
GoTo FormLoadExit
FormLoadExit:
Unload Me
End Sub |
|
|
|
|
|
|
|
|
3. To start the project, insert the following code into the general declarations section: |
|
|
|
|
|
|
|
|
Option Explicit
'Declaration of global variables
Dim DB As Database
Dim wsUpdate As Workspace
Dim nErrFlag As Integer |
|
|
|
|
|
|
|
|
Next, start a new procedure and insert the following code. This code creates a workspace and opens the database. |
|
|
|
|
|
|
|
|
Public Sub OpenDB()
On Error GoTo OpenDBErr
Dim dbName As String
nErrFlag = 0 'Reset the error flag
dbName = App.Path + "\abc.mdb"
'Open the workspace and database
Set wsUpdate = DBEngine.CreateWorkspace("WSUpdate", "admin", "")
Set DB = wsUpdate.OpenDatabase(dbName, True)
GoTo OpenDBExit
OpenDBErr:
MsgBox Trim(Str(Err)) + " " + Error$(Err), vbCritical, "OpenDB"
nErrFlag = Err
OpenDBExit:
End Sub |
|
|
|
|
|